<?php

namespace app\admin\model\daily;

use think\Model;


class Dailys extends Model
{

    

    

    // 表名
    protected $name = 'daily_dailys';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'goout_type_name_text',
        'stay_type_name_text'
    ];
    

    
    public function getGooutTypeNameList()
    {
        return ['未出差' => __('未出差'), '开始出差' => __('开始出差'), '出差中' => __('出差中'), '出差结束' => __('出差结束')];
    }

    public function getStayTypeNameList()
    {
        return ['未住宿' => __('未住宿'), '开始住宿' => __('开始住宿'), '住宿中' => __('住宿中'), '结束住宿' => __('结束住宿')];
    }


    public function getGooutTypeNameTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['goout_type_name']) ? $data['goout_type_name'] : '');
        $list = $this->getGooutTypeNameList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStayTypeNameTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['stay_type_name']) ? $data['stay_type_name'] : '');
        $list = $this->getStayTypeNameList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
